<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的订单</title>
    <link rel="stylesheet" href="/shop/css/reset.css">
    <link rel="stylesheet" href="/shop/css/main.css?v=1">
    <script type="text/javascript">
        SITEURL = '{:C("SITE_URL")}';
    </script>
</head>
<body>
    <div class="soucan-tab">
        <div><span class="on">待收餐</span></div>
        <div><span>已收餐</span></div>
    </div>
    <!-- 待收餐 -->
    <ul class="dscan-list dis">
        <empty name="unfinishOrderList">
            <img src="/shop/images/nonedan.png" style="display:block;margin:0 auto;" />
        <else />
        <volist name="unfinishOrderList" id="vo">
        <li>
            <dl>
                <dd><span>{$vo['menu_week']} {:date('m-d', $vo['menu_date'])}</span><em>订单编号：{$vo['order_sn']}</em></dd>
                <dd><var>配餐时间</var><span>{$vo['menu_week']} {:date('m-d', $vo['menu_date'])} {$deliverTime}</span></dd>
                <volist name="vo.goods" id="go">
                <dd><span>{$go['goods_name']} x {$go['goods_num']}</span></dd>
                </volist>
            </dl>
        </li>
        </volist>
        </empty>
    </ul>

    <!-- 已收餐 -->
    <ul class="dscan-list">
        <empty name="finishOrderList">
            <img src="/shop/images/nonedan.png" style="display:block;margin:0 auto;"/>
        <else />
        <volist name="finishOrderList" id="vo">
        <li>
            <dl>
                <dd><span>{$vo['menu_week']} {:date('m-d', $vo['menu_date'])}</span><em>订单编号：{$vo['order_sn']}</em></dd>
                <volist name="vo.goods" id="go">
                    <dd><span>{$go['goods_name']} x {$go['goods_num']}</span></dd>
                    <eq name="go.comment_star" value="0"><dd class="qping"><a href="javascript:;" id="{$go['id']}">去评价<span></span></a></dd></eq>
                </volist>

            </dl>
        </li>
        </volist>
        </empty>
    </ul>


    <!-- 评论弹框 -->
    <div class="ping" style="display:none;">
        <div class="ping-wp">
            <div class="ping-tit clearfix"><span></span></div>
            <img src="/shop/images/kt.png" class="kt" alt="" />
            <h2 class="ping-wt">香菇滑鸡煲老鸭炖盅套餐文字标题最多两行香菇行香菇滑鸡煲老鸭炖盅套餐文字标题最多两行</h2>
            <div class="ping-xin"><span></span><span></span><span></span><span></span><span></span></div>

            <!-- 存储红心个数的隐藏input -->
            <input type="hidden" value="0" id="xin" />
            <input type="hidden" value="0" id="pxin" />
            <div class="ping-wark"><textarea placeholder="菜品口味如何？" id="pingText"></textarea></div>
            <div class="ping-btns">
                <input type="submit" value="提交" class="btn" id="pingId" />
            </div>
            <!-- 吓一条评论 -->
            <div class="next-ping">
                <span class="tit">点评下一道：</span>
                <p>香菇滑鸡煲老鸭炖盅套餐</p>
                <em class="tu"></em>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="/shop/js/jquery.min.js"></script>
<script type="text/javascript">
    $('.soucan-tab span').each(function(i,e){
        $(e).click(function(){
            $('.soucan-tab span').removeClass('on');
            $(e).addClass('on');
            $('.dscan-list').hide();
            $('.dscan-list').eq(i).show();
        });
    });

    //设置评论弹框

    function pingLun(id){
        $.post(SITEURL + 'wechat/shop/getComment',{'comment_id':id},function(data){
            $('.ping').show();
            var datas = data.data;
            var nowgoods = datas.goods;
            $('.kt').attr('src',nowgoods.goods_image);
            $('.ping-wt').text(nowgoods.goods_name);
            $('#xin').val(nowgoods.id);

            if(datas.next){
                $('.next-ping').css({'display':'flex'});
                $('.next-ping').find('p').text(datas.next.goods_name);
                $('.next-ping').attr('nextid',datas.next.id);

                $('.next-ping').click(function(){
                    pingLun(datas.next.id);
                });
            }else{
                $('.next-ping').hide();
            }
        });
    }

    $('.qping').find('a').each(function(i,e){
        $(e).click(function(){
            localStorage.setItem('pingid',$(e).attr('id'));
            pingLun($(e).attr('id'));
        });
    });


    //关闭点评框

    $('.ping-tit span').click(function(){
        $('.ping').hide();
    });


    //选中黑心
    $('.ping-xin span').each(function(i,e){
        $(e).click(function(){
            var val = 0;
            /* if($(e).hasClass('on')){
             $('.ping-xin span').each(function(c,m){
             if(c>=i){
             $(m).removeClass('on');
             }
             });
             val = i;
             }else{*/
            $('.ping-xin span').removeClass('on');
            $('.ping-xin span').each(function(c,m){
                if(c<=i){
                    $(m).addClass('on');
                }
            });

            val = i+1;
            //}

            $('#pxin').val(val);
        });
    });


    /* 提交评论 */
    $('#pingId').click(function(){
        if($('#pxin').val()==0){
            salert('请选择星级');
            return;
        }
        if($.trim($('#pingText').val())==''){
            salert('请填写评论内容');
            return;
        }

        $.post(SITEURL + 'wechat/shop/submitComment',{comment_id:$('#xin').val(),comment:$.trim($('#pingText').val()),star:$('#pxin').val()},function(data){
            if(data.code==0){
                $('#pxin').val(0);
                $('#pingText').val('');
                $('a[id='+localStorage.getItem('pingid')+']').parent().remove();
                localStorage.removeItem('pingid');
                $('.ping').hide();
            }else{
                salert(data.msg);
            }
        });
    });



</script>
</html>